package com.androidhive.androidlistview;

import java.util.HashMap;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;

public class FViewprofile extends Activity {
	SessionManager session;
	DatabaseHandler db=new DatabaseHandler(this);
	String FProfile=new String();
	String [] res=new String[]{};
	 public final static String NAME = "com.example.sample.MESSAGE";
	 public final static String CNU = "com.example.sample.MESSAGE";
	 public final static String EID= "com.example.sample.MESSAGE";
	 public final static String FLOC = "com.example.sample.MESSAGE";
	 
	 String fNAME=new String();
	
	 String fCNU=new String();
	 String fEID=new String();
	 String fFLOC=new String();
	 String fFSTATE=new String();
	 

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_fviewprofile);
		session = new SessionManager(getApplicationContext());
	    HashMap<String, String> user = session.getUserDetails();
	    String farmerId = (user.get(SessionManager.Vendor_Id)); 
      
		TextView heading= (TextView)findViewById(R.id.textView6);
		
	    //textView6
		TextView name = (TextView)findViewById(R.id.textView8);
		TextView cnu = (TextView)findViewById(R.id.TextView01);
		TextView eid = (TextView)findViewById(R.id.TextView03);
		TextView floc = (TextView)findViewById(R.id.TextView02);
		TextView fstate = (TextView)findViewById(R.id.TextView04);
		Log.d("Farmer",farmerId);
		FProfile=db.getFarmerProfile(Integer.parseInt(farmerId));
		Log.d("Sucess","1");
		
		
		res=FProfile.split("#");
			fNAME=res[0];
			fCNU=res[1];
			fEID=res[2];
			Log.d("Sucess","2");
			fFLOC=res[3];
			fFSTATE=res[4];
			Log.d("Sucess","3");
		heading.setText("Welcome "+fNAME+"!!!!");
		name.setText(fNAME);
		cnu.setText(fCNU);
		eid.setText(fEID);
		floc.setText(fFLOC);
		fstate.setText(fFSTATE);
		Log.d("Sucess","4");
		
		
		// Show the Up button in the action bar.
	
	}
	public void editProfile(View view) {
		
		 Intent intent = new Intent(this, FEditProfile.class);
		   
		  
		 Log.d("in viewProfile","6");
		 
		   intent.putExtra(NAME, FProfile);
	    Log.d("in NAME",FProfile);
		 
//		    intent.putExtra(NAME, fNAME);
//		    Log.d("in NAME",fNAME);
//		    intent.putExtra(CNU, fCNU);
//		    Log.d("in CNU",fCNU);
//		    intent.putExtra(EID, fEID);
//		    Log.d("in EID",fEID);
//		    intent.putExtra(FLOC, fFLOC);
		  //  System.out.println("HareKrishna");
		    Log.d("MyApp","I am here");
		    startActivity(intent);
		    Log.d("Sucess","7");
		
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_fviewprofile, menu);
		return true;
	}

	
	

}
